package com.lzh.runke.core.service.impl;

import com.lzh.runke.core.entity.Code;
import com.lzh.runke.core.entity.spec.BaseSpec;
import com.lzh.runke.core.enums.CodeTypeBaseEnum;
import com.lzh.runke.core.mapper.CodeMapper;
import com.lzh.runke.core.service.ICodeService;
import com.lzh.runke.core.web_base.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 通用码表 Service
 *
 * @author xie
 */
@Slf4j
@Service
public class CodeServiceImpl extends BaseServiceImpl<CodeMapper, Code, BaseSpec> implements ICodeService {

    /**
     * 根据码表类型查询
     *
     * @param type CodeTypeBaseEnum
     * @return Result<List < Code>>
     */
    @Override
    public Result<List<Code>> findByType(CodeTypeBaseEnum type) {
        List<Code> codes = mapper.findByType(type);
        return Result.<List<Code>>builder().success(true).data(codes).build();
    }
}
